import request from '@/Utils/request'
// 获得商品分类 params:{type:3,pagenum:1,pagesize:5} pagenum 当前页码值 pagesize 每页显示条数
export function getGoodsCateInfoApi (params) {
  return request({
    method: 'get',
    url: 'categories',
    params
  })
}
// 修改商品分类 data:{cat_name:cat_name}
export function changeGoodsCateApi (id, data) {
  return request({
    method: 'put',
    url: 'categories/' + id,
    data
  })
}
// 删除商品分类
export function delGoodsCateApi (id) {
  return request({
    method: 'delete',
    url: 'categories/' + id
  })
}
// 添加商品分类 data:{cat_pid:分类父亲id,cat_name:cat_name,cat_level:cat_level}
export function addGoodsCateApi (data) {
  return request({
    method: 'POST',
    url: 'categories',
    data
  })
}
// 根据 id 查询分类
export function getGoodsCateByIdApi (id) {
  return request({
    method: 'get',
    url: 'categories/' + id
  })
}
// 根据id获取参数列表 sel:[only or many]
export function getCateAttryIdApi (id, params) {
  return request({
    method: 'get',
    url: `categories/${id}/attributes`,
    params
  })
}
// 添加商品参数
export function addParamsApi (cateId, data) {
  return request({
    method: 'post',
    url: `categories/${cateId}/attributes`,
    data
  })
}
// 获得商品参数更具id
export function getParamsApi (cateId, id, params) {
  return request({
    method: 'get',
    url: `categories/${cateId}/attributes/${id}`,
    params
  })
}
// 修改商品参数
export function changeParamsApi (cateId, id, data) {
  return request({
    method: 'put',
    url: `categories/${cateId}/attributes/${id}`,
    data
  })
}
// 修改商品标签
export function putParamsTagApi (cateId, id, data) {
  return request({
    method: 'put',
    url: `categories/${cateId}/attributes/${id}`,
    data
  })
}
// 删除商品参数
export function delParamsDataApi (cateId, id) {
  return request({
    method: 'delete',
    url: `categories/${cateId}/attributes/${id}`
  })
}
// 获得商品列表
export function getGoodsInfoApi (params) {
  return request({
    method: 'get',
    url: 'goods',
    params
  })
}
// 添加商品列表
// goods_name
// goods_cat
// goods_price
// goods_number
// goods_weight
// goods_introduce
// pics
// attrs
export function addGoodsInfoApi (data) {
  return request({
    method: 'post',
    url: 'goods',
    data
  })
}
// 根据id查询商品
export function getGoodsInfoByIdApi (id) {
  return request({
    method: 'get',
    url: 'goods/' + id
  })
}
// 编辑提交商品
export function changeGoodsInfoApi (id, data) {
  return request({
    method: 'put',
    url: 'goods/' + id,
    data
  })
}
// 删除商品
export function delGoodsInfoApi (id) {
  return request({
    method: 'delete',
    url: 'goods/' + id
  })
}
// 获取商品分类
export function getGoodsListApi () {
  return request({
    method: 'get',
    url: 'categories'
  })
}
// 添加商品
export function addGoodsListApi (data) {
  return request({
    method: 'post',
    url: 'goods',
    data
  })
}
